package com.info.zhiduoduo.repository.mapper.maker;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Condition;
import com.info.zhiduoduo.repository.entity.maker.MakerAlipayPrincipalOrder;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  平台委托人主体的充值,转账订单表, 与支付宝平台的订单一一对应 Mapper 接口
 * </p>
 *
 * @author bob
 * @since 2021-07-11
 */
public interface MakerAlipayPrincipalOrderMapper extends BaseMapper<MakerAlipayPrincipalOrder> {

//	default List<MakerAlipayPrincipalOrder> listByStatus(List<Integer> statusList, int type) {
//		return new MakerAlipayPrincipalOrder().selectList(Condition.create().in("state", statusList).eq("type", type));
//	}

	default MakerAlipayPrincipalOrder findByOrderNo(String orderNo) {
		return new MakerAlipayPrincipalOrder().selectOne(Condition.create().eq("order_no", orderNo));
	}

	@Select(" select * from zdd_maker_alipay_principal_order " +
			" where state in(${statusList}) " +
			" and type = #{type} " +
			" and createtime <= DATE_SUB(NOW(),INTERVAL 2 MINUTE) ")
	List<MakerAlipayPrincipalOrder> listByStatus(List<Integer> statusList, int type);

	@Select(" select id from zdd_maker_alipay_principal_order where state in(1,3,6) and type in (${types}) " +
			" and createtime <= DATE_SUB(NOW(),INTERVAL 2 MINUTE)")
	List<Integer> listProcessingOrderIds(@Param("types") String types);
}
